<?php
/*
 * Created on 29.01.2006
 * 
 * config:
 * file         Filename of file to load.
 * defaultfile  Default file to load, if 'file' does not exists.
 */

m2import('phpinchains/Filter.php');

class IncludeFileFilter extends phpinchains_Filter
{
    
    var $config;

    function doFilter (& $env, & $chain)
    {
        if (file_exists($this->config['file']))
            include($this->config['file']);
        else
        {
            include($this->config['defaultfile']);
        }
        $chain->doFilter($env);
    }
    
    function init (& $config)
    {
        $this->config = & $config;
        if (!$this->config['file'])
            print "LoadFileFilter: attribute 'file' ist required<br/>";
    }

}
?>